﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Hp.Vertica.Client.Internal;
using Hp.Vertica.Client.ViewModels;
using Hp.Vertica.Migration.SqlServer;

namespace Hp.Vertica.Client
{
    /// <summary>
    /// Interaction logic for SqlToVertica.xaml
    /// </summary>
    public partial class SqlToVertica : Window
    {
        private SqlToVerticaViewModel viewModel = new SqlToVerticaViewModel();

        private SqlToVertica()
        {
            InitializeComponent();
            btnEditSource.Click += (s, e) =>
            {
                VerticaConnection conn = new VerticaConnection(viewModel.VerticaSource);
                conn.Owner = this;
                conn.ShowDialog();
            };
            btnNewConnection.Click += (s, e) =>
            {
                SqlConnection conn = new SqlConnection();
                conn.Saved += (s1, e1) =>
                {
                    ServerInstance model = s1 as ServerInstance;
                    //(this.DataContext as SqlToVerticaViewModel).SqlExplorer.Add(
                };
                conn.Owner = this;
                conn.ShowDialog();
            };

            this.DataContext = new SqlToVerticaViewModel();
        }

        public SqlToVertica(VerticaDatabase context)
            : this()
        {
            if (context != null)
            {
                viewModel.VerticaSource = context;
            }
            else
            {
                this.Loaded += (s, e) =>
                {
                    VerticaConnection conn = new VerticaConnection();
                    conn.Owner = this;
                    conn.ShowDialog();
                }; ;
            }
        }

    }
}
